function 检测运行游戏()

mSleep(100)
end
function 提示()
local ui = require "JSON"
--ui_ref = true
init("0",1)
local w_,h_ = getScreenSize() --w < h
local h = w_
local w = h_
ui:new(w*0.7,h*0.8,"2.png","下一步","不玩了","config_1231.dat")
--ui:new(w*0.6,h*0.6,"下一步","退出","config_123.dat")
local p = ui:newPage("")
p:newLine()
p:addLebel(10,1,"为了您能安全的使用脚本!!!","25","left","0,0,0") 
p:newLine(-0.3)
p:addLebel(10,1,"请务必加群看下群文件里的《防老君双重保险》教程!!!","25","left","0,0,0")
p:newLine(-0.3)
p:addLebel(10,1,"有助于提高防老君性能！！！！！！","25","left","250,0,0")
p:newLine(-0.3)
local b = p:newBox(3,0)
b:addCheckBoxGroup(0.9,9,1,"提示框","","我知道了")
p:newLine(0.5)
p:addLebel(10,1,"勾选“我知道了”,以后不再出现此页面")
p:newLine(0.3)
p:addLebel(10,1,"官方QQ群：608765301","30","left","250,0,0",QQ群)
ret,result3 = ui:show()
if ret == 0 then lua_exit() end
print(result3)
end



function 公告服务()
getCloudContent = getCloudContent or function() return nil end
content, err = getCloudContent("暂停游戏", "7CC849F345271557", "没有正确获取到公告信息")
sysLog(string.format("getCloudContent return content = %s, err = %s", tostring(content), tostring(err)));
if err == 0 then
  if string.find(content,"关闭") ~= nil then
    dialog("内部异常紧急暂停脚本，如有疑问联系QQ群 管理人员")
    lua_exit()
  elseif string.find(content,"重要更新") ~= nil then
    dialog(content,7200000000)
    lua_exit()
  end
  
elseif err == 1 then
  --dialog("网络错误")
elseif err == 999 then
  --dialog("未知错误")
end
getCloudContent = getCloudContent or function() return nil end
content, err = getCloudContent("脚本管理", "ECF5453640C0C86D", "没有正确获取到公告信息")
sysLog(string.format("getCloudContent return content = %s, err = %s", tostring(content), tostring(err)));
if err == 0 then
  if string.find(content,"关闭") ~= nil then
    dialog(content)
    lua_exit()
  elseif string.find(content,"一小时") ~= nil then
    dialog(content,3600)
  elseif string.find(content,"二小时") ~= nil then
    dialog(content,7200)
  end
  
elseif err == 1 then
  --dialog("网络错误")
elseif err == 999 then
  --dialog("未知错误")
end
end

tf = createHUD() 
function ddzs(找色数组,备注)
  local x, y =-1,-1
  if 找色数组 ~=nil then
    if 找色数组[1] ~=nil then
      x, y = findMultiColorInRegionFuzzy(找色数组[1],找色数组[2],找色数组[3], 找色数组[4],找色数组[5],找色数组[6],找色数组[7]);
      if x>-1 then
        sysLog(备注)
        if Proportion == 7 or width==1242 then
          mSleep(10)
        else
          showHUD(tf,备注,12,"0xffff0000","0xffffffff",0,581,0,108,22) 
        end
      end
    else
      sysLog(备注.." |空数组b")
    end
  else
    sysLog(备注.." |空数组")
  end
  return x,y
  
end
function  tap(x, y) --封装防检测
  math.randomseed(tostring(os.time()):reverse():sub(1, 7)) --随机种子
  local sjtest = math.random(50,200)
  local index = math.random(1,2)
  x=x+math.random(-6,6)
  y=y+math.random(-6,6)
  touchDown(index,x,y)
  mSleep(sjtest)
  touchUp(index,x,y)
end --封装防检测
function tap1(x,y)
  local at1=math.random(1,10)
  local at3=math.random(10,50)
  touchDown(1,x+at1,y+at1)
  mSleep(at3)
  touchUp(1,x+at1,y+at1)
end
function tap2(x,y)
  local at1=math.random(1,10)
  local at3=math.random(2000,3000)
  touchDown(1,x+at1,y+at1)
  mSleep(at3)
  touchUp(1,x+at1,y+at1)
end
function dian(x,y,c,s)   --x,y为坐标值，c为颜色值，s为相似度，范围0~100。
  local fl,abs = math.floor,math.abs
  s = fl(0xff*(100-s)*0.01)
  local r,g,b = fl(c/0x10000),fl(c%0x10000/0x100),fl(c%0x100)
  local rr,gg,bb = getColorRGB(x,y)
  if abs(r-rr)<s and abs(g-gg)<s and abs(b-bb)<s then
    return true
  end
  return false
end



function 稳定滑动(x1,y1,x2,y2)
touchDown(0, x1, y1)
mSleep(650)
local abs =math.abs
移动的距离x=abs(x1-x2);移动的距离y=abs(y1-y2)
if  移动的距离x < 移动的距离y then
  移动的距离x = 移动的距离y
end
sysLog(移动的距离x)	
local 需要移动的次数 = 移动的距离x
local 持续滑动的次数 = 0

local 每次需要移动的距离x = (x2-x1)/需要移动的次数 * 10
local 每次需要移动的距离y = (y2-y1)/需要移动的次数 * 10
sysLog("每次移动的距离XY"..每次需要移动的距离x..","..每次需要移动的距离y)	
mSleep(60) 
repeat
  持续滑动的次数=持续滑动的次数+1
  下一个移动的坐标x = 每次需要移动的距离x * 持续滑动的次数 + x1
  下一个移动的坐标y = 每次需要移动的距离y * 持续滑动的次数 + y1
  touchMove(0,下一个移动的坐标x,下一个移动的坐标y)
  mSleep(3)           sysLog("我在移动"..持续滑动的次数.."坐标为："..下一个移动的坐标x..","..下一个移动的坐标y)
until(持续滑动的次数*10 > 需要移动的次数)
sysLog("我在忍耐") -- mSleep(100)
touchUp(0, x2, y2)  
mSleep(100)   		sysLog("我松手了")

end
tf1 = createHUD() 
function 提分显示(内容5)
if Proportion == 7 or width==1242 then
  mSleep(10)
else
  showHUD(tf,内容5,12,"0xffff0000","0xffffffff",0,581,0,108,22) 
end
end
function 打字(内容5)
if Proportion == 7 or width==1242 then
  --showHUD(tf1,内容5,12,"0xffff0000","0xffffffff",0,155,744,158,22) 
  mSleep(10)
elseif 六九手机==1 then
  showHUD(tf1,内容5,12,"0xffff0000","0xffffffff",0,242,694,158,22)
elseif 三五手机==1 then
  showHUD(tf1,内容5,12,"0xffff0000","0xffffffff",0,242,742,158,22) 
elseif 十六手机==1 then
  showHUD(tf1,内容5,12,"0xffff0000","0xffffffff",0,235,779,158,22) 
end
end
tft = createHUD()
function 平板老君(内容5)
if Proportion == 7 or width==1242 then
  --showHUD(tf1,内容5,12,"0xffff0000","0xffffffff",0,155,744,158,22) 
  mSleep(10)
elseif 六九手机==1 then
  showHUD(tft,"🌟"..内容5,12,"0xffff0000","0xffffffff",0,56,664,158,22) 
elseif 三五手机==1 then
  showHUD(tft,"🌟"..内容5,12,"0xffff0000","0xffffffff",0,90,715,158,22) 
end

end
--function SZ(找色数组,备注)--------------------------------找色数组
-- x, y = findMultiColorInRegionFuzzy(找色数组[1],找色数组[2],找色数组[3], 找色数组[4],找色数组[5],找色数组[6],找色数组[7]);
-- if x>-1 then
--   sysLog(备注)
--  else
--  end
--  return x,y
--end      

function 文字(x,y,x1,y1,颜色,出现字符)
local ocr, err = createOCR({
type = "tesseract",
path = "[external]",
lang = "chi_sim" 
})
if ocr ~= nil then
  string.trim = function(s)
    return s:match'^%s*(.*%S)' or ''
  end
  
  local code, text = 0, ""
  code, text = ocr:getText({
  rect = {x,y,x1,y1},
  diff = {颜色},
  whitelist = 出现字符
  })
  sysLog("code = " .. tostring(code) .. ", text = " .. text:trim())
  return text:trim()
else
  sysLog("createOCR failed: " .. tostring(err))
end

end


